#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define uint unsigned int

#define YES cout << "YES" << '\n'
#define NO cout << "NO" << '\n'
#define endl '\n'
const int INF = 1e9;
const int MOD = 998244353;
using namespace std;

/*思考

*/
ll q_pow(ll a, ll n, ll p) {
    ll ans = 1l;
    while (n) {
        if (n & 1) ans = (ll)ans * a % p;
        a = (a * a) % p;
        n >>= 1;
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, p;
    cin >> a >> b >> p;
    ll ans = q_pow(a, b, p);
    cout << a << "^" << b << " mod " << p << "=" << ans << endl;
    return 0;
}